// import { viewImageApiPrefix } from '@/settings'
export default {
  data () {
    return {
	  imgUrL: 'http://imgcdn.jufengnr.net/',
      avatar: require('../../static/image/avatar/avatar.png'),
      memberInfo: {}
    }
  },
  computed: {
    ifLoginInfo () {
		// #ifndef MP-WEIXIN
		return this.memberInfo.length > 0
		// #endif
    },
    handlieAvatar () {
		// #ifndef MP-WEIXIN
      if (this.memberInfo.appMemberInfo && this.memberInfo.appMemberInfo.avatar) {
        return this.imgUrL + this.memberInfo.appMemberInfo.avatar
      }
	  // #endif
      return this.avatar
    }
  },
  created () {
    this.getMemberInfo(false)
  },
  onShow(){
	this.getMemberInfo(false)  
  },
  mounted () {
	  uni.$emit('getInfo', this.getMemberInfo())
  },
  methods: {
    getMemberInfo (update) {
      uni.request({
          method: 'GET',
          url: 'http://shop.jufengnr.net/jufeng-api/api/app_member/all_member_info',
          data: {
		  companyId: 22
		  },
          header: {
      		'content-type': 'application/x-www-form-urlencoded',
      		'canna-device-info': 'WEB',
      		'canna-system-code': 'JUFENG',
      		'x-token': uni.getStorageSync('x-token') ? uni.getStorageSync('x-token') : ''
      		},
          dataType: 'json',
		  success: (res) => {
			if (res.data.msg == '无权限用户') {
				uni.showToast({
				    title: '请先登录',
					icon: 'none',
				    duration: 2000
				});
				uni.navigateTo({
					url: '/pages/login/index'
				})
				return
			}
		  	this.memberInfo = res.data.data
		  	this.memberInfo.wxMemberInfo = {}
		  	uni.setStorageSync('memberInfo', res.data.data)
			// console.log(uni.getStorageSync('memberInfo'))
		  	// this.$emit('getMemberInfo')
		  	// console.log(this.memberInfo)
		  }
      })
    }
  }
}
